package cn.studyjava.verify.code12306.common.enums;

/**
 * <p>
 * Description:
 * </p>
 * 
 * @author: zsljava
 * @version 1.0.0
 * <p>
 * History:
 * -----------------------------------------------
 * @Date: 2017年10月16日 下午5:42:16
 * @author: zsljava
 * @version 1.0.0
 * @OP: Create
 * -----------------------------------------------
 * </p>
 *
 * @since
 * @see
 */
public enum VerifyEnum {

	
	VERIFY_AUTH_FAIL_PARAMS_IS_NULL("1000", "参数不能为空"),
	VERIFY_AUTH_FAIL_CODE_NOT_EXIST("1001", "验证码已失效"),
	VERIFY_AUTH_FAIL_CHOICE_ERROR("1002", "选择验证码错误"),
	VERIFY_AUTH_FAIL_APPID_NOT_EXIST("1003", "验证码已失效"),
	/**
	 * 系统错误
	 */
	VERIFY_AUTH_FAIL("1004", "验证失败"),
	VERIFY_AUTH_FAIL_SIGNATURE("1005", "signature 错误"),
	VERIFY_AUTH_FAIL_ATTACK_INT("1006", "可能存在临界值攻击行为"),
	VERIFY_AUTH_FAIL_TIMEOUT("1007", "时间戳有效时间为10s已超时"),
	VERIFY_AUTH_NOT_EXIST("1008", "验证不存在"),
	
	/**
	 * 组件错误
	 */
	SERVICE_REIDS_CONNECTION_FAIL("2001", "Redis服务不能链接"),
	
	/**
	 * 服务器错误
	 */
	SERVER_REQ_PATH_NOT_FOUND("3001", "请求资源路径不存在"),
	
	VERIFY_AUTH_SUCCESS("9999","成功");
	
	private String code;
	
	private String msg;
	
	VerifyEnum(String code, String msg){
		this.code = code;
		this.msg = msg;
	}
	
	public String getCode(){
		return this.code;
	}
	
	public String getMsg(){
		return this.msg;
	}
	
	public static String getMsg(String code){
		for (VerifyEnum enums : values()) {
			if (enums.getCode().equalsIgnoreCase(code)) {
				return enums.getMsg();
			}
		}
		return null;
	}
	
	public static VerifyEnum getEnumByCode(String code){
		for (VerifyEnum enums : values()) {
			if (enums.getCode().equalsIgnoreCase(code)) {
				return enums;
			}
		}
		return null;
	}
}
